package com.en.effectiveJava.chapter2.singleton3;

/**
 * 单例模式测试类
 * {@link PrivateConstructor} {@link StaticFactory} {@link EnumSingleton}
 * Create by EN
 * On 24/05/18 4:41 PM
*/
public class SingletonTest {

    public static void main(String[] args) throws Exception {
        StaticFactory staticFactory = StaticFactory.getInstance();
        staticFactory.say();

        PrivateConstructor.INSTANCE.say();

        //利用反射调用私有构造器，创建实例
        /*Class privateConstructorClass = Class.forName("com.en.effectiveJava.chapter2.singleton3.PrivateConstructor");
        Constructor constructor = privateConstructorClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        PrivateConstructor privateConstructor  = (PrivateConstructor) constructor.newInstance();

        privateConstructor.say();*/

        EnumSingleton.INTSTANCE.say();

    }

}
